<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户注册</title>
		<link rel="stylesheet" type="text/css" href="layui/css/layui.css"/>
		<script src="layui/layui.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<form class="layui-form" action="">
			<input type="hidden" name="token" value="231649c6-3627-4a7c-b1e0-20da6cad93d6" />
		  <div class="layui-form-item">
		    <label class="layui-form-label">登录名</label>
		    <div class="layui-input-inline">
		      <input type="text" id="loginName" name="loginName" required  lay-verify="required" placeholder="请输入登录名" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">密码</label>
		    <div class="layui-input-inline">
		      <input type="password" id="pwd" name="pwd" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">邮箱</label>
		    <div class="layui-input-inline">
		      <input type="text" id="email" name="email" required  lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">手机号</label>
		    <div class="layui-input-inline">
		      <input type="text" id="mtel" name="mtel" required  lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		  </div>
		</form>
		 
		<script>
		//Demo
		layui.use(['form','jquery'], function(){
		  var form = layui.form;
		  var $ = layui.jquery;
		  //监听提交
		  form.on('submit(formDemo)', function(data){
			//data.elem 代表触发监听事件的按钮
			//data.field 代表表单数据:{key/value}
			//data.form 代表整个表单
			$.post(
				'http://stuapi.ysd3g.com/api/CreateUser'//请求地址
				,data.field
				,function(res){//回调函数
					console.log(typeof res);
					layer.msg(''+res.success);
				},'json'
			); 
		    return false;//阻止表单提交
		  });
		});
		
		</script>
	</body>
</html>
